#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void reverse(char *s, int len)
{
    char *p = s, *q = s + len - 1;
    char t;
    while (p < q)
    {
        t = *p, *p = *q, *q = t;
        p++, q--;
    }
}

int main()
{
    char A[1010], B[1010];
    int nCase, lena, lenb;
    scanf("%d", &nCase);
    while (nCase--)
    {
        scanf("%s%s", A, B);
        lena = strlen(A);
        lenb = strlen(B);
        reverse(A, lena); //反过来以后，AB都从个位开始
        reverse(B, lenb);
        if (lena < lenb)
            memset(A + lena, '0', lenb - lena); //补开头的0到AB长度一样
        else
            memset(B + lenb, '0', lena - lenb);
        int i, carry = 0; //carry是进位
        for (i = 0; i < lena || i < lenb; i++)
        {
            A[i] = A[i] - '0' + B[i] - '0' + carry;
            if (A[i] >= 10)
                carry = 1, A[i] -= 10;
            else
                carry = 0;
        }
        if (carry) //AB所有位都计算完以后可能还有进位
            A[i++] = carry;
        while (i--)
            putchar(A[i] + '0');
        putchar('\n');
    }
    return 0;
}
